package com.ww.sound_emission.controller;

import com.ww.sound_emission.domain.ActivityParticipants;
import com.ww.sound_emission.service.ActivityParticipantsService;
import com.ww.sound_emission.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/activity-participants")
public class ActivityParticipantController {

    @Autowired
    private ActivityParticipantsService activityParticipantService;

    // 参与活动
    @PostMapping
    public Result<String> addParticipant(@RequestBody ActivityParticipants participant) {
        activityParticipantService.save(participant);
        return Result.success("参与活动成功");
    }

    // 取消参与
    @DeleteMapping("/{id}")
    public Result<String> deleteParticipant(@PathVariable Long id) {
        activityParticipantService.removeById(id);
        return Result.success("取消参与成功");
    }
}